package com.macro.mall.tiny.modules.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.macro.mall.tiny.modules.pms.model.PmsSkuStock;
import com.macro.mall.tiny.modules.pms.mapper.PmsSkuStockMapper;
import com.macro.mall.tiny.modules.pms.service.PmsSkuStockService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * sku的库存 服务实现类
 * </p>
 *
 * @author macro
 * @since 2024-08-15
 */
@Service
public class PmsSkuStockServiceImpl extends ServiceImpl<PmsSkuStockMapper, PmsSkuStock> implements PmsSkuStockService {

    @Override
    public List<PmsSkuStock> getSkuStockList(Long id, String keyword) {
        QueryWrapper<PmsSkuStock> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(PmsSkuStock::getProductId, id);
        queryWrapper.lambda().like(keyword != null, PmsSkuStock::getSkuCode, keyword);
        return this.list(queryWrapper);
    }

    @Override
    public boolean update(List<PmsSkuStock> skuStockList) {
        return this.updateBatchById(skuStockList);
    }
}
